package com.gthncz;

import java.util.ArrayList;
import java.util.List;

public class VisualVMDemo {


    public static void main(String[] args) throws InterruptedException {
        List<Long> container = new ArrayList<>(1000 * 100);
        // test new thread
        ArrayList<Thread> threads = new ArrayList<>(1000);
        for (int i=0; i<1000; ++i){
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int j=0; j<100; ++j){
                        container.add(Thread.currentThread().getId());
                        System.out.println(Thread.currentThread().getId() + "--" + j);
                        try {
                            Thread.currentThread().sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
            thread.start();
            threads.add(thread);
        }
        for (Thread thread: threads){
            thread.join();
        }
    }

}
